let item=[
    {
        "id":"1",
        "img":"shop/images/1.jpg",
        "name": "1号水果",
        "pric": "99",
        "info":["含大量的维生素C，能降低血液中的胆固醇。","含有天然维生素P，加速复原受伤的皮肤组织功能"],
    },
    {
        "id":"2",
        "img":"shop/images/2.jpg",
        "name": "2号水果",
        "pric": "77",
        "info":["含大量的维生素C，能降低血液中的胆固醇。","含有天然维生素P，加速复原受伤的皮肤组织功能"]
    },
    {
        "id":"3",
        "img":"shop/images/3.jpg",
        "name": "3号水果",
        "pric": "66",
        "info":["含大量的维生素C，能降低血液中的胆固醇。","含有天然维生素P，加速复原受伤的皮肤组织功能"]
    }
];
let urlId=location.search.substr(location.search.indexOf("=")+1);
let infoHc=[];		
let prod=new Vue({
    el:".warp",
    data:{
        dat:[],
        mete:0
    },
    methods:{
        point(){
            prod.dat=(item.filter(function(item){
                return item.id ==urlId;}
            ))[0];
            if(localStorage.hc&&localStorage.hc!="[]"){
                infoHc=JSON.parse(localStorage.hc);
                infoHc.find(value=>{
                    if(value.id==urlId){
                        prod.mete=value.num;
                    }
                })
            }
        },
        join(){
            prod.mete=(prod.mete)+1;
            let {name,img,pric}=prod.dat;
            if(prod.mete==1){								
                infoHc.push({
                    id:urlId,
                    name:name,
                    img:img,
                    pric:pric,
                    num:prod.mete,
                    check:true
                });
            }else{
                infoHc.find(function(value,index,infoHc){
                    if(value.id==urlId){
                        value.num=prod.mete;
                    }
                });
            }
            localStorage.hc=JSON.stringify(infoHc);
        }
    }
});
prod.point()